package com.ux.lg
{
	import com.ux.util.JsUtil;
	import com.ux.util.StringUtils;
	
	import flash.external.ExternalInterface;

	/**
	 * @author winnie
	 */	
	public class Member
	{
		
		public static const LOGIN_URL : String = "https://family.lge.co.kr/MemberLoginFormCmd.laf";
		public static const LOGOUT_URL : String = "http://family.lge.co.kr/MemberLogoutFormCmd.laf";
		
		/**
		 * 쇼룸 브랜드 명 반드시 넣어 주세요. 
		 */		
		public static var BRAND_CODE : String = "";
		
		private static var _url:String = "";
		
		public static function get URL():String
		{
			if( !_url || _url.length < 1 )
			{
				_url = JsUtil.getJsVars( "document.URL" ) as String;
			}
			
			if( StringUtils.contains( _url, "?" ) )
			{
				_url = _url.slice(0, _url.lastIndexOf("?")+1);
			}
			
			return _url;
		}
		
		public static function lgLogin( pageNum:String="" ):void
		{
			if( BRAND_CODE == "" )
			{
				throw new Error( "브랜드 명을 넣어주세요" );
				return;
			}
			var loginURL : String = LOGIN_URL;
			//var loginURL = "http://ummatest.lge.com/MemberLoginFormCmd.laf"; //테스트 서버 url
			
			loginURL = loginURL + "?from=POPUP";
			loginURL = loginURL + "&brand="+BRAND_CODE;
			loginURL = loginURL + "&opener="+"1";
			loginURL = loginURL + "&frame_name="+"frame_countPage"
			loginURL = loginURL + "&return_url=" + escape( URL + '?pageNum=' + pageNum );
			
			JsUtil.windowOpen( loginURL, "로그인", 420, 460, 50, 50 ); 
		}
		
		public static function lgLogout( pageNum:String="" ):void
		{
			if( BRAND_CODE == "" )
			{
				throw new Error( "브랜드 명을 넣어주세요" );
				return;
			}
			
			var logoutURL : String = LOGOUT_URL;
			//var logoutURL = "http://ummatest.lge.com/MemberLogoutFormCmd.laf"; //테스트 서버 url
			
			logoutURL = logoutURL + "?brand="+BRAND_CODE;
			logoutURL = logoutURL + "&return_url=" + (URL + '?pageNum='+String(pageNum));
			
			JsUtil.link( logoutURL ); 
		}
		
		
		
		
		
		
		
		
		
		public function Member()
		{
		}
	}
}